package com.freecat.xmqgct.mvp.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.freecat.xmqgct.R;
import com.freecat.xmqgct.mvp.model.entity.Project;
import com.freecat.xmqgct.mvp.ui.activity.BaseActivity;

import java.util.List;


public class ProjectAdapter extends BaseAdapter {
    private Context context;

    List<Project> list;
    private BaseActivity.IBack iBack;
    private boolean canDel;


    public ProjectAdapter(Context context) {
        this.context = context;
    }

    public ProjectAdapter(Context context, List<Project> list, BaseActivity.IBack iBack, boolean canDel) {
        this.context = context;
        this.list = list;
        this.iBack = iBack;
        this.canDel = canDel;
    }


    @Override
    public int getCount() {
        return list.size();
    }


    @Override
    public Object getItem(int position) {

        return list.get(position);
    }

    @Override
    public long getItemId(int position) {

        return list.get(position).getId();
    }


    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        final ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_project_res, parent, false);
            holder = new ViewHolder();
            holder.tv_project_mc=convertView.findViewById(R.id.tv_item_projcet_mc);
//            holder.tv_project_xx=convertView.findViewById(R.id.tv_item_projcet_xx);
            holder.tv_project_dz=convertView.findViewById(R.id.tv_item_projcet_dz);

            holder.tv_project_mc.setText(list.get(position).getMc());
//            holder.tv_project_xx.setText(list.get(position).getXx());
            holder.tv_project_dz.setText(list.get(position).getDz());

            convertView.setTag(holder);

        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        return convertView;
    }


    private class ViewHolder {
        TextView mState;
        TextView mStateText;
        TextView tv_project_mc;
        TextView tv_project_xx;
        TextView tv_project_dz;
    }


}